Okay.
So in this video, we're going to continue working on our donut tool by creating an eating animation
for it.
In order to create animations on roadblocks, we first have to create a model that represents a player's
character model.
So when we create an animation, it knows exactly which limbs to perform the animation on.
To create a character model, we can go to the Avatar tab.
And select the Rig Builder button.
From here we can select an AR 15 block rig and spot it in front of us.
And I'll just make sure that this rig is level with the ground so we can see what we're doing.
Now that I have my character model, I'm going to make my tool a child of my model.
That way my model equips it.
The character equips the tool.
So as you can see, it is equipped.
My donut.
Then I can open up the animation editor in the Avatar tab.
I'll close out the console here real quick and then I can select this rig, this character to start
animating it.
It'll ask you to name it.
I'll just name it eating.
And now we can start animating our dummy here, our rig.
So here you have a timeline that starts at zero and goes all the way up to one second.
And of course, we can increase how long we want this animation to be, but one second long should be
good for now.
And in this case, since we're going to be doing an eating animation, I want to animate the head and
the right arm of the model.
So using this little plus button here, I'll add the head as a part.
I want to animate and I'll add the right lower arm, the right upper arm and the right hand as well.
I want to animate everything in the arm.
Now, at the beginning here, we want to define a starting position for our animation.
And as you know, when we hold a tool in Roblox, it starts off the character with their arm at a 90
degree angle.
This is how the character looks when they hold a tool.
This is just the default way of holding tools and roadblocks.
So we want to make sure we start off at this default pose.
Otherwise, if we didn't, if we had the arm down at the resting position here, then when this animation
gets run, it'll move our arm back down and then back up to perform the eating animation, which will
look a little strange.
So I'm going to put it at the 90 degree position for now.
Now I kind of want to start maybe around here, I guess, is where we can start rotating the arm towards
the character's head.
So I'll just rotate the arm here.
And then maybe I want to rotate this part of the arm so I have it rotate towards the face and then have
the hand rotate towards the face as well.
And I'll.
I'll move this whole thing a little bit more.
Maybe this one a little bit more.
Okay.
And then I want to have my arm move up so it's actually towards my mouth.
And since the donuts a little offset to my mouth, I maybe want to move my arm kind of like that.
So now the donuts kind of in my mouth.
So when I go to the start of my animation here at 0 seconds and then hit spacebar to play it, you see
it moves the donut towards my mouth.
And maybe I want it to be a little slower.
Salt drag all these keyframes by using this top keyframe here, which selects all the ones below it.
And that looks a little better.
So now that the donut is in my face, I want the head to move down and look like it's biting the donut.
And so here I can select my head.
And have it rotate down a little.
And then maybe a little bit later, it rotates back up to the starting position.
Now if I play it, it kind of looks like my character is eating it.
And if you've noticed throughout this entire track here, if we go along frame by frame, you'll notice
my head is moving down the whole time, which I don't want.
And that's because after this default head keyframe right here, it starts animating my head towards
the other head keyframe I defined here.
So if I want to keep my head still, I'll just copy this keyframe and paste it for however long I want
to keep the head still.
And then once it reaches past this key frame right here, then the head will start moving down.
And it does it a little bit too quick so I can select these key frames here, kind of move them out
a bit.
Here we go.
We kind of got like a goofy little E.T. animation.
And then afterwards, I want to make sure my arm goes back to the default holding position.
So I'll just copy all these keyframes and move them, like down here.
And I want to make sure that my arm stays at this position here until my head is done moving.
So I'll copy all this and move it to here, copy all this, move it to here.
Because otherwise, if I don't, if I didn't have those key frames here, then my arm would start moving
back when I don't want it to.
So it'll look like I'm kind of biting air.
So I want to make sure I copy all these key frames and move it here.
Then after all these key frames are reached, it'll start animating towards the next set of key frames.
So now if we play the whole thing.
Looks like I'm eating my donut.
Now, another cool thing we can do with animations is add an event, and this event will fire when the
animation plays and it reaches that event point.
So for example, here, maybe when the head bites down, like right here, when the head bites down,
I can right click the track and add an animation event and I can name it like bite.
And you can put whatever parameter in here.
I'm just going to leave it blank for now.
But basically, when the animation plays in our script, when it reaches this animation event point,
it will fire this event and then we can connect a script to do whatever we like.
So for example, maybe I can play an eating sound when this event fires.
So I move my arm to my mouth and then the head moves down this event fire so that I can play an eating
sound.
And the head goes back up and the arm returns to the default position.
Another thing I can do with my keyframes is that I can right click them and change the easing style
of them.
So maybe instead of it being linear, which means the movement of the arm is constant, which isn't
exactly natural, I can change it to something like cubic.
And I can actually do it for all of my keyframes.
If I make it cubic, you'll see how the animation will look a little bit different.
So now if I play my animation.
You can kind of see how my arm doesn't move in a linear fashion anymore.
And maybe, let's see what other easing styles we can do.
Maybe I can do elastic.
And we'll give it an elastic like a rubber band.
Look.
That looks really weird.
And I can change the easing direction.
Maybe I want to do in and out.
And maybe I want to put it back to Cubic.
Look at that.
That looks a little more natural.
And we'll take a couple of look at another one like bounce.
It'll make my arms look like they're bouncing.
But I think I'm going to keep it at Kubik for now.
If you want to learn more about easing styles and easing directions, then I'll attach a robotics article
to this lecture so you can learn more about them.
But for now, I think we have a pretty good animation here that we can use for our donut.
So now what we want to do is want to hit these three little dots here and we want to change the animation
priority.
And what this basically means is what priority does this animation have over other animations?
So, for example, you know, the character has like default animations, like when it's walking.
It has a default animation when it equips a tool.
What priority do we want to set this animation over other animations?
And we want to set this animation to action because we're performing an action here.
If we didn't set this animation priority to action, then when we try to play the animation, the default
holding animation where your arm sticks out, which I believe has an animation priority of idle, if
we didn't have this track at an animation priority of movement or higher.
And you have different levels of action.
So maybe you have multiple different action animations and you want them to have higher precedence over
other action animations.
So Redbox Studio gives us the option to do that here.
Now we can publish our animation and use it by hitting the published roadblocks button.
And then I'll just name it eating donut.
Then I can hit submit.
Now you have to copy the ID in the link to use your animation so you can go to this link and open up
your browser and copy the number to your clipboard and then come back once you've got your number.
Now that you have your number copied, we're going to go to our tool here and we're going to remove
it from our dummy and put it back into the workspace.
And then we don't need our dummy anymore, so I'll just delete them.
And then I'll fix the orientation of my donut.
And then inside my donut, I'm going to insert a new object, a new animation object.
And inside the animation there's this animation ID property and you're going to want to paste the number
you copied from your link.
Now that we have our animation in our tool, we can now implement the animation in our script, our
local script, and we'll get to do that in the next lecture.
I'll see you there.